const app = getApp();
Page({
    data: {
    },
    onLoad: function(t) {
      var that =this
      var a = that.data.tabInfo
      app.ihttpGet('https://www.58zltc.com/api.php/Commission/getMyteam/openid/' + app.globalData.openid, function (res) {
        wx.hideLoading()
        that.setData({
          info: res.data
        })
      })
    },
    backto: function (e) {
      wx.navigateBack({})
    },
    //设置副队长
    set_leader2:function(e){
      var t = this
      var leader2_openid = e.currentTarget.dataset.openid
      var type = e.currentTarget.dataset.type
      if(type == 'set'){
        wx.showModal({
          title: '提示',
          cancelText: '暂不',
          content: '副队长分红将按设置比例从您的分红中扣除，是否设置？',
          cancelColor: '#1c1c1e',
          confirmColor: '#ff4d49',
          success: function (e) {
            app.ihttpGet('https://www.58zltc.com/api.php/Commission/set_leader2/leader2_openid/' + leader2_openid +'/type/set', function (res) {
              wx.hideLoading()
              var res = res.data
              if (res.error > 0) {
                wx.showModal({
                  title: '提示',
                  content: res.msg,
                })
              } else {
                wx.showToast({
                  title: res.msg,
                })
                setTimeout(function () {
                  t.onLoad();
                }, 2000)
              }
            })
          }
        })
      }else{
        //取消副队长
        app.ihttpGet('https://www.58zltc.com/api.php/Commission/set_leader2/leader2_openid/' + leader2_openid + '/type/remove', function (res) {
          wx.hideLoading()
          var res = res.data
          if (res.error > 0) {
            wx.showModal({
              title: '提示',
              content: res.msg,
            })
          } else {
            wx.showToast({
              title: res.msg,
            })
            setTimeout(function () {
              t.onLoad();
            }, 2000)
          }
        })
      }
     
      
    }
});